|
Aliases In the previous report, we used the data source with the "frxDBDataSet1" name and the following fields: "CustNo," "Company," "Phone," and "FAX." Accordingly, we had to insert something like "[frxDBDataSet1."CustNo"]" into the report. Does it seem to be quite clear? No, it does not. One would want to rename the data source, and the field, naming it "Our clients" and "Number" respectively. However, "frxDBDataSet1" is a name of the componenet, which does not support spaces. And "CustNo" is a name of the field; it cannot be renamed directly (without database restructuring). There is however a way out. The user can use so-called pseudonyms or aliases in such situations. Both the data source and the field possess second names, i.e. aliases, which can easily be modified (the original names, of course, are not modifiable). If a name has an alias, this alias is what is used in FastReport. Otherwise, the original name is used. It is very easy to rename a data source and its fields in FastReport. This is performed from Delphi environment. To open the alias editor, double-click on the "TfrxDBDataSet" component. You can modify the data source name, names of its fields, and select the fields you would need in the report. Let us rename the source and fields (see picture):
Note, that an alias of the source can be modified without using the alias editor. To perform this, modify the "UserName" property of the "TfrxDBDataSet" component. Now we need to modify the report, as the names of the fields have been changed. To modify the names of fields in objects, it is easier to use the fourth way, which was described in the "List of clients Report" chapter. Move the mouse cursor to the "Text" object so that the button in the right part of the object would appear, click on the button, and select a necessary field in the list. As you can see, now the data source name and its fields’ names are more than understandable. The only thing remains to be said is that it is better to perform the operation of assigning an alias in the very beginning, before starting building a report. This can help to avoid subsequent field renaming in the report. |